package com.yc.ycpaimon.repository

import com.yc.jetpacklib.extension.ycFlow
import com.yc.jetpacklib.net.YcResult
import com.yc.ycpaimon.data.entity.VersionEntity
import com.yc.ycpaimon.data.json.VersionJson
import com.yc.ycpaimon.mapper.VersionMapper
import com.yc.ycpaimon.net.GithubApi
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow

/**
 * Creator: yc
 * Date: 2022/2/17 18:31
 * UseDes:
 */
class VersionRepo(private val mApiGithub: GithubApi) {
    private val mVersionMapper by lazy { VersionMapper() }
    fun versionUpdate(): Flow<YcResult<VersionEntity>> = ycFlow {
        val json = mApiGithub.versionUpdate()
        send(YcResult.Success(mVersionMapper.map(json)))
    }
    fun versionUpdate22(): Flow<YcResult<VersionEntity>> = ycFlow {
        val json = mApiGithub.versionUpdate()
        send(YcResult.Success(mVersionMapper.map(json)))
    }
    fun versionUpdate33(): Flow<YcResult<VersionEntity>> = ycFlow {
        val json = mApiGithub.versionUpdate()
        send(YcResult.Success(mVersionMapper.map(json)))
    }
   suspend fun versionUpdate2(): VersionJson {
        val json = mApiGithub.versionUpdate()
       return json
    }
    suspend fun versionUpdate3(): VersionJson {
        val json = mApiGithub.versionUpdate()
        return json
    }
}